<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="look">点击查看数据</button>

    <script>
        document.getElementById('look').onclick = function() {
            var xhr = new XMLHttpRequest();
            xhr.open('get', 'data/package.json', true);
            xhr.send();
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        console.log(xhr.responseText);
                        var res = xhr.responseText //字符串
                        var obj = JSON.parse(res);
                        console.log(obj);
                        console.log(obj.data);
                    }
                }
            }
        }
    </script>
</body>

</html>